#include "npc1bomb.h"
#include "../common.h"

namespace fireplane{

	Npc1Bomb::Npc1Bomb( EffectType type ):
		Effect(type),_bomb(NULL)
	{}

	Npc1Bomb::~Npc1Bomb()
	{}

	void Npc1Bomb::init(CreateCmd* cmd)
	{
		CreateNpc1Bomb* tcmd = (CreateNpc1Bomb*)cmd;
		_bomb = NULL;

		_bomb = CCSprite::create("effect/npc1bomb/0.png");
		addChild(_bomb);

		CCPoint pos = tcmd->worldPos;
		pos = Effect::getAllEffectParent()->convertToNodeSpace(pos);
		this->setPosition(pos);

		_bomb->runAction(CCFadeOut::create(0.5f));
		_bomb->runAction(CCScaleTo::create(0.5f,4.0f));

		scheduleUpdate();
	}

	void Npc1Bomb::destroyThis()
	{
		this->removeFromParentAndCleanup(true);
	}

	void Npc1Bomb::update( float delta )
	{
		if(_bomb->numberOfRunningActions() == 0){
			destroyThis();
		}
	}
}